package cc.magicjson.minigame.demo.ddd.application;


import cc.magicjson.minigame.demo.ddd.application.query.GameQueryDTO;
import cc.magicjson.minigame.demo.ddd.application.query.GameQuery;
import cc.magicjson.minigame.demo.ddd.domain.model.Game;
import cc.magicjson.minigame.demo.ddd.domain.model.GameId;
import cc.magicjson.minigame.demo.ddd.domain.port.GameRepository;
import org.springframework.stereotype.Service;

@Service
public class GameQueryService implements GameQuery {
    private final GameRepository gameRepository;

    public GameQueryService(GameRepository gameRepository) {
        this.gameRepository = gameRepository;
    }

    @Override
    public GameQueryDTO findById(GameId id) {
        Game game = gameRepository.findById(id);
        return new GameQueryDTO(game.getId().value(), game.getName().value(), game.getStatus());
    }
}